home *** CD-ROM | disk | FTP | other *** search
- Path: sun001.spd.dsccc.com!spd!jmccarty
- From: jmccarty@spd.dsccc.com (Mike McCarty)
- Newsgroups: comp.lang.c
- Subject: Re: Tradition or what?
- Date: 15 Feb 1996 18:53:20 GMT
- Organization: DSC Communications Corporation, Plano, Texas USA
- Message-ID: <4fvvf0$f9c@sun001.spd.dsccc.com>
- References: <1996Feb13.115611.73989@cc.usu.edu>
- NNTP-Posting-Host: aplo139.spd.dsccc.com
-
- In article <1996Feb13.115611.73989@cc.usu.edu>,
- Erik van Renselaar <erik@cc.usu.edu> wrote:
- )Hi all,
- )
- )Can anyone tell me what the use is of returning
- )the same value for the function and one of the
- )output parameters, like it is done in strcpy?
- )Why return a string for the function if the
- )result is in its first parameter as well?
- )
- )Is this just tradition or is it actually useful
- )for anything?
- )
- )Erik
-
-
- It would have been much better had such tools returned the END ADDRESS
- rather than the beginning. Someone thought it might be nice to do things
- like
- puts(srtcat(strcpy(buffer,"The string is: "),string));
-
- Which I consider to be ugly.
-
- Had the routines returned the end address (i.e. of the terminating nul)
- one could have done this:
-
- char *location;
-
- location = buffer;
-
- location = strcpy(location,"The string is: ");
- location = strcat(location,string);
- location = strcat(location," ");
- ...
- puts(buffer);
-
- Which I consider to be elegant.
-
- And not paid the overhead of reprocessing the strings to get to the end
- over and over.
-
- So IMHO, there is no particular use for those return addresses. They are
- pretty much useless.
-
- Mike
- ----
- char *p="char *p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);}
-
- I don't speak for DSC. <- They make me say that.
-